// Achievement by G3X / GeXeH - Enjoy
// Version 1.0

// Achievement: Be submerged underwater inside a vehicle for a total of 2 hours.

local time = achievements.GetValue( "Submerged", "total", 0 )

local target = 7200
local function Update()
	local ply = LocalPlayer()
	if ( !ValidEntity( ply ) ) then return end
	
	if ( time != target && (ply:WaterLevel() == 3) && (!ply:IsOnGround()) && (ply:InVehicle()) ) then
		time = math.Clamp( time + 1, 0, target )
		achievements.SetValue( "Submerged", "total", time )
		if ( time >= target ) then timer.Destroy( "Achievements.Submerged" ) end
	end
	
	achievements.Update( "Submerged", time / target, achievements.FormatTime( time, "h:m:s" ) )
end
timer.Create( "Achievements.Submerged", 1, 0, Update )

achievements.Register( "Submerged", "Be submerged underwater inside a vehicle for a total of 2 hours.", "achievements/submerged", time / target, string.FormattedTime( time, "%02i:%02i" ) )